<template>
  <div class="footer">
    <div class="header-main justify">
      <div class="dib center-body">
        <app-link
          type="buss_cooperation"
          :text="$t('footer.business_cooperation')"
          class="footer-btn"
          :class="{ 'link-active': feature === 'business' }"
          @click.native="featureFn('business')"
        ></app-link>
        <app-link
          type="contact_us"
          :text="$t('footer.market_cooperation')"
          class="footer-btn"
          :class="{ 'link-active': feature === 'market' }"
          @click.native="featureFn('market')"
        ></app-link>
        <app-link
          type="join_us"
          :text="$t('footer.join_us')"
          class="footer-btn"
          :class="{ 'link-active': feature === 'joinUs' }"
          @click.native="featureFn('joinUs')"
        ></app-link>
      </div>
      <div class="center-hack"></div>
      <div class="dib center-body tel-wrapper">
        <img src="../assets/footer_tel.png" alt="联系电话" class="tel-icon" />
        <span class="tel-num">86&nbsp;/&nbsp;28-60159634</span>
      </div>
    </div>
    <!-- 加入我们弹出框 -->
    <el-dialog
      :visible.sync="showjoinUs"
      width="880px"
      custom-class="dialog footer-dialog join-dialog"
      top="0"
      :show-close="false"
      @closed="closeDialog('joinUs')"
    >
      <app-link
        type="close"
        :size="20"
        class="dialog-close-btn"
        @click.native="closeDialog('joinUs')"
      />
      <div class="dialog-header"><el-divider>Join us</el-divider></div>
      <div class="join-body">
        <div class="join-container">
          <p class="join-title">我们正在招聘的职位</p>
          <el-divider class="join-body-divider"></el-divider>
          <div class="job-panel">
            <div>
              <div
                v-for="(e, i) in employes"
                :key="e._id"
                class="job-col"
                :class="jobClazz(i)"
              >
                <div class="job-content">
                  <p class="job-title">{{ e.job }}</p>
                  <p class="job-info">招聘-{{ e.count }}人</p>
                  <p class="job-info">地点：{{ e.site }}</p>
                </div>
              </div>
            </div>
          </div>
          <div class="contact-type-panel">
            <div class="contact-type-col">
              <p>请将您的履历或案例发送至</p>
              <p class="contact-type">222222222@qq.com</p>
            </div>
            <div class="contact-type-col">
              <p>或拨打HR热线</p>
              <p class="contact-type">15928847789</p>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>
    <!-- 联系我们(市场合作与媒体联系)弹出框 -->
    <el-dialog
      :visible.sync="showmarket"
      width="70%"
      custom-class="dialog footer-dialog contact-dialog"
      top="0"
      :show-close="false"
      @closed="closeDialog('market')"
    >
      <app-link
        type="close"
        :size="20"
        class="dialog-close-btn"
        @click.native="closeDialog('market')"
      />
      <p class="contact-tel">Contact us&nbsp;-&nbsp;<span class="tel">13900000000</span></p>
      <div class="contact-address-info">
        <div class="address-text">1410,BlockC,Jintian International, No.288, Taisheng Road, Chengdu / 成都市<span class="adddress-cn"> 太升路288号 锦天国际C座 1410</span></div>
      </div>
      <div class="contact-img">
        <img class="address-map-img" src="../assets/company_address_map_img.jpg" alt="联系我们">
      </div>
    </el-dialog>
    <!-- 商务合作弹出框 -->
    <contact-us :show="showbusiness" @close="closeDialog('business')"></contact-us>
  </div>
</template>

<script>
import ajax from '../req'

export default {
  name: 'Footer',
  props: {
    flag: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      feature: '',
      showbusiness: false,
      showmarket: false,
      showjoinUs: false,
      employes: [] // 招聘信息
    }
  },
  watch: {
    flag (v) {
      this.feature = v.split('_')[0]
    }
  },
  created () {
    ajax.getJSON('/contacts', (err, res) => {
      if (!err) {
        this.contacts = res.contacts
      }
    })
    ajax.getJSON('/employes', (err, res) => {
      if (!err) {
        this.employes = res.employes
      }
    })
  },
  methods: {
    featureFn (f) {
      this.feature = f
      this['show' + f] = true
    },
    jobClazz (i) {
      return i === 2 ? '' : 'job-col' + (i + 1)
    },
    closeDialog (f) {
      this.feature = ''
      this['show' + f] = false
    }
  }
}
</script>

<style lang="less">
@import url('../vars.less');

.footer {

  .link-active {
    color: #FBB03B;
  }

  .footer-btn {

    &:hover {
      color: rgba(275,172,60,.5);
    }

    &:not(:first-child) {
      margin-left: 50px;
    }
  }
}

.dialog {
  margin-top: 0;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 0;
  box-shadow: none;
  background-color: black;

  .el-dialog__header {
    padding: 0;
  }

  .el-dialog__body {
    padding: 0;
    background-color: black;
    color: gray;
    position: relative;
  }
}

.footer-dialog {
  background-color: black;

  .el-divider {
    background-color: #626262;
  }
  .el-divider__text {
    background-color: black;
    font-weight: bold;
    color: #626262;
  }

  .dialog-header {
    width: 80%;
    margin: auto;
    height: 50px;
    padding-top: 1px;
  }
}

.dialog-close-btn {
  position: absolute;
  top: 8px;
  right: 5px;
  z-index: 3;

  &:hover {
    color: #FBB03B;
  }
}

// 加入我们弹出框
.join-dialog {
  .join-body {
    padding: 25px 0 50px 0;
    background-color: #161616;
  }
  .join-container {
    width: 80%;
    margin: auto;
  }
  .join-title {
    text-align: center;
    margin-bottom: 25px;
  }
  .join-body-divider {
    background-color: @hoverColor;
    margin: 20px 0;
  }
  .job-panel {
    padding: 0 10px;
    font-size: 0;
  }
  .job-col {
    width: 20%;
    font-size: 14px;
    display: inline-block;
    overflow-x: hidden;
    text-align: center;
    box-sizing: border-box;
  }
  .job-content {
    text-align: left;
    display: inline-block;
  }
  .job-title {
    color: @hoverColor
  }
  .job-info {
    margin-top: 10px;
    font-size: 12px;
  }
  .job-col1 {
    text-align: left;
  }
  .job-col2 {
    text-align: left;
    padding-left: 3%;
  }
  .job-col4 {
    text-align: right;
    padding-right: 3%;
  }
  .job-col5 {
    text-align: right;
  }
  .contact-type-panel {
    font-size: 0;
    text-align: center;
    margin-top: 30px;
  }
  .contact-type-col {
    width: 50%;
    display: inline-block;
    font-size: 14px;
  }
  .contact-type {
    margin-top: 10px;
    color: @hoverColor;
    font-size: 16px;
    font-weight: bold;
  }
}

// 联系我们(市场合作与媒体联系)弹出框
.contact-dialog {
  max-width: 1360px;
  .contact-tel {
    font-size: 16px;
    font-weight: bold;
    padding: 15px 0;
    text-align: center;
    color: white;
  }

  .tel {
    color: @hoverColor;
  }
  .contact-address-info {
    padding: 0 5px 20px 5px;
    font-family: Helvetica;
    text-align: center;
    font-size: 0;

    &::before {
      content: "";
      width: calc((100% - 700px) / 2);
      height: 1px;
      display: inline-block;
      background: linear-gradient(to right, rgba(255, 255, 255, 0) , rgba(255, 255, 255, 1));
      vertical-align: middle;
    }

    &::after {
      content: "";
      width: calc((100% - 700px) / 2);
      height: 1px;
      display: inline-block;
      background: linear-gradient(to right, rgba(255, 255, 255, 1) , rgba(255, 255, 255, 0));
      vertical-align: middle;
    }
  }
  .address-text {
    display: inline-block;
    font-size: 14px;
    vertical-align: middle;
  }
  .adddress-cn {
    color: white;
  }
  .contact-img {
    box-sizing: border-box;
    padding: 0 5px;
  }
  .address-map-img {
    width: 100%;
    max-width: 1356px;
    height: 350px;
  }
}

// 商务合作弹出框
.business-dialog {
  .business-content {
    position: relative;

    &::before {
      content: "";
      display: block;
      height: 76px;
    }

    &::after {
      content: "";
      display: block;
      width: 100%;
      height: 320px;
      background: url('../assets/footer_buss_bg.jpg') no-repeat 0 0;
      background-size: 100% 100%;
    }
  }

  .business-content-main {
    position: absolute;
    width: 80%;
    height: 100%;
    left: 10%;
    top: 0;
    padding: 20px 0 40px 0;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 0;
  }

  .dialog-business-item {
    display: inline-block;
    height: 100%;
    width: 210px;
    background-color: rosybrown;

    &:not(:first-child) {
      margin-left: calc((100% - 630px) / 2);
    }
  }

  .business-image {
    width: 100%;
    height: 100%;
  }
}

@media screen and (max-height: 768px) {
  .contact-dialog {
    .address-map-img {
      height: 280px;
    }
  }

  .business-dialog {
    .business-content {
      &::before {
        height: 67px;
      }
      &::after {
        height: 280px;
      }
    }
  }
}
</style>
